package edu.tjhsst.androidIntranet;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;
import edu.tjhsst.androidIntranet.news.NewsEntryPicker;
import edu.tjhsst.androidIntranet.period8.EighthBlockPicker;

public class TaskPicker extends IntranetListActivity {
	
	static final String[] TASKS = new String[] {
		"News",
		"Eighth Period",
		"Student Directory",
//		"Browse your Shares",
	};
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.task_picker);
		setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, TASKS));
		ListView lv = getListView();
		lv.setOnItemClickListener(new TaskListener());
		
	}
	
	private class TaskListener implements OnItemClickListener {
		@Override
		public void onItemClick(AdapterView<?> parent, View view, int position,
				long id) {
			Log.d("TaskPicker", "ClickReceived");
			String task = (String) parent.getItemAtPosition(position);
			Log.d("TaskPicker", "Task Name: " + task);
			if(task.equals("News")) {
				Log.d("TaskPicker", "News Clicked");
				TaskPicker.this.startActivity(new Intent("android.intent.action.VIEW", new Uri.Builder().path(("content://tjIntranet/news/")).build(), TaskPicker.this, NewsEntryPicker.class));
			} else if(task.equals("Eighth Period")) {
				Log.d("TaskPicker", "Eighth Clicked");
				TaskPicker.this.startActivity(new Intent("android.intent.action.VIEW", new Uri.Builder().path(("content://tjIntranet/eighth/")).build(), TaskPicker.this, EighthBlockPicker.class));
			} else if(task.equals("Student Directory")) {
				
			}
		}
	}

}
